package homework;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.Scanner;

public class Test01 {
    public static void main(String[] args) {
        System.out.println("请输入您的个人信息");
        Scanner scan = new Scanner(System.in);
        System.out.print("请输入您的姓名：");
        String name = scan.next();
        System.out.print("请输入您的密码：");
        String pwd = scan.next();
        System.out.print("请输入您的昵称：");
        String nick=scan.next();
        System.out.print("请输入您的年龄：");
        int age=scan.nextInt();

        User user=new User(name,pwd,nick,age);
        FileOutputStream fos=null;
        ObjectOutputStream oos=null;
        try {
            fos=new FileOutputStream(name+".obj");
             oos=new ObjectOutputStream(fos);
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            oos.writeObject(user);
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            oos.close();
        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}
